package actions.staffs;

import java.util.Date;
import java.util.List;

import data.Account;
import data.AccountRole;
import data.Department;
import data.Staff;
import data.StaffRole;
import actions.base.BaseAction;

public class New extends BaseAction {
	
	Staff staff;
	
	List<Department> departments;
	
	List<StaffRole> roles;
	
	Account account;
	
	@Override
	public String execute() throws Exception {
		departments = services.getDepartments();
		roles = services.getStaffRoles();
		if(staff != null){
			services.createAccount(account);
			account = services.getAccount(account.getUsername(), account.getPassword());
			staff.setAccount(account);
			staff.setDateJoined(new Date());
			staff.setStaffStatus(true);
			services.createStaff(staff);
		}
		return SUCCESS;
	}

	/**
	 * @return the account
	 */
	public Account getAccount() {
		return account;
	}

	/**
	 * @param account the account to set
	 */
	public void setAccount(Account account) {
		this.account = account;
	}

	/**
	 * @return the staff
	 */
	public Staff getStaff() {
		return staff;
	}

	/**
	 * @param staff the staff to set
	 */
	public void setStaff(Staff staff) {
		this.staff = staff;
	}

	/**
	 * @return the departments
	 */
	public List<Department> getDepartments() {
		return departments;
	}

	/**
	 * @param departments the departments to set
	 */
	public void setDepartments(List<Department> departments) {
		this.departments = departments;
	}

	/**
	 * @return the roles
	 */
	public List<StaffRole> getRoles() {
		return roles;
	}

	/**
	 * @param roles the roles to set
	 */
	public void setRoles(List<StaffRole> roles) {
		this.roles = roles;
	}

}
